package com.cqie.practicaltraining.controller;

import com.cqie.practicaltraining.config.result.R;
import com.cqie.practicaltraining.dto.UserDto;
import com.cqie.practicaltraining.service.impl.UserServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api")
@Api(value = "登录管理")
public class loginController {
    @Autowired
    private UserServiceImpl userService;

    @PostMapping("/login")
    @ApiOperation(value = "用户登录")
    public R login(@RequestBody @Validated UserDto userDto) {
        return userService.login(userDto);
    }

    @PostMapping("/logout")
    @ApiOperation(value = "用户退出")
    public R quit() {
        return userService.logout();
    }
    @GetMapping("/getCurrentUser")
    @ApiOperation(value = "获取用户信息")
    public R getUserInfo() {
        return userService.getCurrentUser();
    }
}
